import { PublicInterface } from '@/interface/public';
import { useOtherInfoForm } from '../form/use-otherInfoForm';

/**
 * 其他信息
 */

export function useOtherInfoData(proTableBox: PublicInterface.ProTableValue, drawerObj: any) {
  const getOtherInfoData = () => {
    otherInfoList(otherInfoData.initParam).then(data => {
      otherInfoData.data = data || {};
    });
  };
  const { otherInfoForm, saveAddOtherInfoForm, openOtherInfoForm } = useOtherInfoForm(getOtherInfoData);

  let otherInfoData = reactive<any>({
    initParam: {
      rosterId: ''
    },
    data: [],
    // 表格配置项
    columns: [
      {
        label: '宿舍编号',
        prop: 'dormNumber'
      }
    ],

    headButtonList: [],
    rowButtonList: [
      {
        label: 'edit',
        type: 'primary',
        icon: 'edit',
        attrs: {
          plain: true
        },
        // permissionCode: 'roster:saveOther',
        methods: () => {
          const params = {
            ...otherInfoData.data,
            rosterId: drawerObj.value.id
          };
          openOtherInfoForm('编辑其他信息', params);
        }
      }
    ]
  });

  return { otherInfoData, otherInfoForm, saveAddOtherInfoForm, getOtherInfoData };
}
